#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#define n 5
int find_max(int* a, int begin, int end)
{
	int i = begin;
	int max = a[begin];
	for (i = begin;i <= end;i++)
	{
		if (a[i] > max)
		{
			max = a[i];
		}
	}
	return max;
}
int same(int* a, int i,int begin, int end)
{
	int j = begin;
	for (j = begin;j <= end;j++)
	{
		if (i == a[j])
		{
			return 1;
		}
	}
	return 0;
}
int mex(int* a, int begin, int end)
{
	int i = 0;
	int max = find_max(a, begin, end);
	for (i = 0;i < max;i++)
	{
		int is = same(a,i,begin,end);
		if (is==0)
		{
			return i;
		}
	}
}
int main()
{
	//int n;
	//scanf("%d", &n);
	int a[n];
	int f[n];
	int i = 0;
	for (i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
	}
	for (i = 0;i < n;i++)
	{
		int _f = mex(a, 0, i);
		f[i] = _f;
	}
	for (i = 0;i < n;i++)
	{
		printf("%d ", f[i]);
	}
	return 0;
}